<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,initial-scale=1.0,width=device-width" />
  <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
  <link rel="stylesheet" href="../../css/animate.css">
  <link rel="stylesheet" href="../../iconfont/iconfont.css">
  <link rel="stylesheet" href="../../css/mescroll.css">
  <link rel="stylesheet" href="../../css/gloab.css">
  <title>升级VIP</title>
</head>
<body>
  <div id="app">
    <div id="public-header" style="padding-bottom:1rem;">
      <div id="statusbar"></div>
      <header class="public-header">
        <div class="public-header-lf iconfont icon-fanhui" @click="javascript:api.closeWin();"></div>
        <div class="public-header-title">升级VIP</div>
      </header>
      <div class="take-name auto" style="font-size:0.32rem;color:#fff;margin-top:0.24rem;">付费升级</div>
    </div>
    <div class="vip-one">
      <div class="vip-one-top flex">
        <div class="vip-one-top-lf F3">
          <span class="personal-header-vip" style="font-size:0.36rem;">VIP</span>&nbsp;
          <span class="personal-header-vip" style="font-size:0.24rem;">付费升级</span>
        </div>
        <div class="vip-one-top-rt F1">￥{{takeVipPrice}}</div>
      </div>
      <div class="vip-one-top" v-html="content" style="font-size:14px;">

      </div>
      <!-- <p style="color:#888;font-size:0.28rem;">无直推要求，可拿一代奖励10%</p> -->
      <div class="vip-one-pay" @click="takeVip">立即支付(￥{{takeVipPrice}})</div>
    </div>
    <!-- <div class="tuijian-shengji">
      <div class="tuijian-shengji-title auto">推荐人升级</div>
      <div style="width:94%;margin:0.2rem auto 0; font-size: 16px;" v-html="upgrade_content" >

      </div>
    </div> -->
  </div>
</body>
<script src="../../script/api.js"></script>
<script src="../../script/jquery.js"></script>
<script src="../../script/mescroll.js"></script>
<script src="../../script/vue.js"></script>
<script src="../../script/app.js"></script>
<script src="../../script/jsencrypt.js"></script>
<script src="../../script/fastclick.js"></script>

<script>
var vm;
var mescroll;
apiready=function(){
  api.removeLaunchView();
  setBar("statusbar");
  setFont(750);
  startVue();
  $(".public-progress").fadeOut(1000);
  setTimeout(function(){
    $(".public-progress").css({"display":"none"});
  },2000);
}
function startVue(){
  vm = new Vue({
    el:"#app",
    data:{
      gdtt:['100','1000','5000','10000','20000','50000'],
      num:0,
      takeVipPrice:'',
      userInfo:[],
      content:'',
      upgrade_content:'',
    },
    created:function(){
      this.getTakeVipPrice();
      this.getUserInfo();
    },
    methods:{
      close:function(){
        api.closeToWin({
            name: 'root'
        });
      },
	  getUserInfo:function(){
	    api.ajax({
	        url: apiUrl+'/api/user/index',
	        method: 'post',
	        data: {
	            values: {
	                token:$api.getStorage('token'),
	            },
	        }
	    },function(ret, err){
	  			console.log(JSON.stringify(ret))
	        if (ret.code==1) {
	          vm.userInfo = ret.data;
	        } else {
	         vm.userInfo = ret.data;
	        }
	    });
	  },
      takeVip:function(){
        if (vm.userInfo['type_id']=='2') {
          msg('您已是VIP,无需升级');
          return;
        }else if(vm.userInfo['type_id']>='2'){
          msg('当前VIP等级高于VIP，无需升级');
          return;
        }else if(vm.userInfo['type_id']>='2'){
          msg('当前等级高于VIP，无需升级');
          return;
        }
        api.toast({
            msg: '订单已提交，请前往支付',
            duration: 2000,
            location: 'middle'
        });
        setTimeout(function(){
          api.openWin({
              name: 'pay',
              url: '../home/pay.html',
              pageParam: {
                // nickname:vm.nickname,
                release_price:vm.takeVipPrice,
                types:4,
				type:8,
				ad:2,
                // ad_id:ret.data,
              }
          });
        },500);
        // api.ajax({
        //     url: apiUrl+'api/home/removeVip',
        //     method: 'post',
        //     data: {
        //         values: {
        //             uid: post_en($api.getStorage('uid')),
        //             price:post_en(vm.takeVipPrice),
        //         },
        //     }
        // },function(ret, err){
        //     if (ret.status) {
        //       api.toast({
        //           msg: ret.msg,
        //           duration: 2000,
        //           location: 'middle'
        //       });
        //       setTimeout(function(){
        //         api.closeWin({});
        //       },500);
        //     } else {
        //       api.toast({
        //           msg: ret.msg,
        //           duration: 2000,
        //           location: 'middle'
        //       });
        //     }
        // });
      },
      getTakeVipPrice:function(){
        api.ajax({
            url: apiUrl+'/api/index/userLevelInfo',
            method: 'post',
            data: {
				values: {
				    type:2
				},
            }
        },function(ret, err){
			console.log(JSON.stringify(ret))
            if (ret.code==1) {
              vm.takeVipPrice = ret.data.price;
              vm.content = ret.data.description;
              vm.upgrade_content = ret.data.upgrade_content;
            } else {
              vm.takeVipPrice = '';
              vm.content = '';
            }
        });
      },
    }
  })
}

</script>
</html>
